﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.OleDb;

namespace WebSite_CodeMan.BLL
{
    public class NoteInfo
    {
        /// <summary>
        /// 添加、修改类别信息
        /// </summary>
        /// <param name="ClassID">类别ID</param>
        /// <param name="strClassName">类别名称</param>
        /// <param name="strClassDes">类别简介</param>
        /// <param name="strClassKey">类别关键字</param>
        /// <param name="strT_ClassLeave">类别等级</param>
        /// <param name="strRemark">备注</param>
        /// <returns></returns>
        public static bool EditClassMes(string ClassID, string strClassName, string strClassEnName, string strClassDes, string strClassKey, string strT_ClassLeave, string strRemark, string strType, string strList, string strNote)
        {
            try
            {
                OleDbParameter[] parm = {  new OleDbParameter("@T_ClassName", strClassName),
                                           new OleDbParameter("@T_ClassEnName", strClassEnName),
                                           new OleDbParameter("@T_ClassLeave", strT_ClassLeave),
                                           new OleDbParameter("@T_ClassKey", strClassKey),
                                           new OleDbParameter("@T_ClassDes", strClassDes),
                                           new OleDbParameter("@T_ListTemplete", strList),
                                           new OleDbParameter("@T_NoteTemplete", strNote),
                                           new OleDbParameter("@Remark",strRemark),
                                           new OleDbParameter("@T_NoteClassID",ClassID)};
                string strSql = "  UPDATE T_Note_Class SET T_ClassName=@T_ClassName,T_ClassEnName=@T_ClassEnName,T_ClassLeave=@T_ClassLeave,T_ClassKey=@T_ClassKey,T_ClassDes=@T_ClassDes,T_ListTemplete=@T_ListTemplete,T_NoteTemplete=@T_NoteTemplete,Remark=@Remark WHERE T_NoteClassID=@T_NoteClassID";
                if (!string.IsNullOrEmpty(strType))
                {
                    strSql = " INSERT INTO T_Note_Class(T_ClassName,T_ClassEnName,T_ClassLeave,T_ClassKey,T_ClassDes,T_ListTemplete,T_NoteTemplete,Remark,T_NoteClassID) VALUES(@T_ClassName,@T_ClassEnName,@T_ClassLeave,@T_ClassKey,@T_ClassDes,@T_ListTemplete,@T_NoteTemplete,@Remark,@T_NoteClassID)";
                }
                return (DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, strSql, parm) > 0) ? true : false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取分类信息数据
        /// </summary>
        /// <param name="strClassID">为空 获取所有分类信息</param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteClassMes(string strClassID)
        {
            try
            {
                string strFilter = (string.IsNullOrEmpty(strClassID)) ? " ORDER BY T_ClassLeave ASC " : string.Format(" WHERE T_NoteClassID='{0}' ", strClassID);
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT * FROM T_Note_Class {0} ", strFilter), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取类别的模板文件名称
        /// </summary>
        /// <param name="strClass"></param>
        /// <returns></returns>
        public static string GetClassTempleate(string strClass, string strType)
        {
            try
            {
                string strSql = string.Format(" SELECT {0} FROM T_Note_Class WHERE T_NoteClassID='{1}' ", strType, strClass);
                return DBUnlity.AccessHelper.ExecuteScalar(DBUnlity.AccessHelper.ConnectionString, strSql, null).ToString();
            }
            catch
            {
                return (strType == "T_ListTemplete") ? "List.html" : "Note.html";
            }

        }
        /// <summary>
        /// 获取类别的等级层次
        /// </summary>
        /// <param name="strClass"></param>
        /// <returns></returns>
        public static string GetClassLeave(string strClass)
        {
            try
            {
                string strSql = string.Format(" SELECT T_ClassLeave FROM T_Note_Class WHERE T_NoteClassID='{0}' ",strClass);
                return DBUnlity.AccessHelper.ExecuteScalar(DBUnlity.AccessHelper.ConnectionString, strSql, null).ToString();
            }
            catch
            {
                return "";
            }

        }
        /// <summary>
        /// 获取分类名称信息
        /// </summary>
        /// <param name="strClassID">ID</param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteClassName(string strClassID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT T_ClassName FROM T_Note_Class WHERE T_NoteClassID IN ('{0}')", strClassID.Replace(",", "','")), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取分类名称信息
        /// </summary>
        /// <param name="strClassID">ID</param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteClassName()
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, " SELECT T_NoteClassID,T_ClassName,T_ClassEnName,T_ClassLeave  FROM T_Note_Class WHERE T_NoteClassID =T_ClassLeave", null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取子分类信息
        /// </summary>
        /// <param name="strClassID">ID</param>
        /// <returns></returns>
        public static DataTable GetNoteClassHtmlMes(string strClassID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteDataSet(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT T_NoteClassID,T_ClassName,T_ClassEnName,T_ClassLeave  FROM T_Note_Class  WHERE T_ClassLeave like '%{0}%' and  T_ClassLeave like '%,%' ", strClassID.Replace(",", "','")), null).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取子分类的所有ID
        /// </summary>
        /// <param name="strClassID">ID</param>
        /// <returns></returns>
        public static string GetNoteClassIDMes(string strClassID)
        {
            try
            {
                string strnewID = string.Empty;;
                DataTable dtData=DBUnlity.AccessHelper.ExecuteDataSet(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT T_NoteClassID  FROM T_Note_Class  WHERE T_ClassLeave like '%{0}%' ", strClassID), null).Tables[0];
                if (dtData.Rows.Count>0)
                {
                    for (int i = 0; i < dtData.Rows.Count; i++)
                    {
                        strnewID += dtData.Rows[i]["T_NoteClassID"].ToString()+",";
                    }
                }
                return strnewID.Substring(0,strnewID.Length);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取分类信息下的内容信息数量
        /// </summary>
        /// <param name="strClassID">ID</param>
        /// <returns></returns>
        public static string GetClassNoteCountMes(string strClassID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteScalar(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT COUNT(*)  FROM T_Note_Info  WHERE T_NoteClassID ='{0}' ", strClassID), null).ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取关键字
        /// </summary>
        /// <param name="Top"></param>
        /// <returns></returns>
        public static OleDbDataReader GetHotKey(string Top)
        {
            try
            {
                Top = (string.IsNullOrEmpty(Top)) ? "" : " TOP " + Top;
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" select {0} T_NoteKey from (select DISTINCT  T_NoteKey, T_BrowerCount FROM T_Note_Info  Order by T_BrowerCount DESC)", Top), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取分类名称信息
        /// </summary>
        /// <param name="strClassID">ID</param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteClassENName(string strClassID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT DISTINCT T_ClassEnName FROM T_Note_Class WHERE T_NoteClassID IN ('{0}')", strClassID.Replace(",", "','")), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 删除分类信息
        /// </summary>
        /// <param name="strClassID"></param>
        /// <returns></returns>
        public static bool DelClassMes(string strClassID, string strClassLeave)
        {
            try
            {
                //删除本类
                bool DelClass = (DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" DELETE FROM T_Note_Class WHERE T_NoteClassID ='{0}'", strClassID), null) > 0) ? true : false;
                //删除下边的所有子类
                DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" DELETE FROM T_Note_Class WHERE T_ClassLeave like ('%{0}%')", strClassID), null);
                //删除内容信息的评论
                DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" DELETE FROM T_Leave_Info WHERE T_NoteID IN (SELECT T_NoteID FROM T_Note_Info WHERE T_NoteClassID IN ('{0}'))  ", strClassLeave.Replace(",", "','")), null);
                //删除与主类 子类相关的所有内容信息
                DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" DELETE FROM T_Note_Info WHERE T_NoteClassID IN ('{0}')", strClassLeave.Replace(",", "','")), null);
                return DelClass;
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        /// <summary>
        /// 根据ClassID获取内容ID
        /// </summary>
        /// <param name="strClassID"></param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteID(string strClassLeave)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT T_NoteID FROM T_Note_Info WHERE T_NoteClassID IN ('{0}')", strClassLeave.Replace(",", "','")), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 添加、修改内容信息
        /// </summary>
        /// <param name="ClassID">类别ID</param>
        /// <param name="strClassName">类别名称</param>
        /// <param name="strClassDes">类别简介</param>
        /// <param name="strClassKey">类别关键字</param>
        /// <param name="strT_ClassLeave">类别等级</param>
        /// <param name="strRemark">备注</param>
        /// <returns></returns>
        public static bool EditNoteMes(string ClassID, string strTitle, string strClassID, string strClassDes, string strClassKey, string strDateTime, string strNoteMes, string strFlag, string strNoteImage, string strRemark)
        {
            try
            {
                OleDbParameter[] parm = {  new OleDbParameter("@T_NoteTitle", strTitle),
                                           new OleDbParameter("@T_NoteClassID", strClassID),
                                           new OleDbParameter("@T_NoteDes", strClassDes),
                                           new OleDbParameter("@T_NoteKey", strClassKey),
                                           new OleDbParameter("@T_DateTime", strDateTime),
                                           new OleDbParameter("@T_NoteMes", strNoteMes),
                                           new OleDbParameter("@T_NoteFlag",strFlag),
                                           new OleDbParameter("@T_NoteImage",strNoteImage),
                                           new OleDbParameter("@Remark",strRemark),
                                           new OleDbParameter("@T_NoteID", ClassID)};
                string strSql = "  UPDATE T_Note_Info SET T_NoteTitle=@T_NoteTitle,T_NoteClassID=@T_NoteClassID,T_NoteDes=@T_NoteDes,T_NoteKey=@T_NoteKey,T_DateTime=@T_DateTime,T_NoteMes=@T_NoteMes,T_NoteFlag=@T_NoteFlag,T_NoteImage=@T_NoteImage,Remark=@Remark WHERE T_NoteID=@T_NoteID";
                if (string.IsNullOrEmpty(ClassID))
                {
                    strSql = " INSERT INTO T_Note_Info(T_NoteTitle,T_NoteClassID,T_NoteDes,T_NoteKey,T_DateTime,T_NoteMes,T_NoteFlag,T_NoteImage,Remark) VALUES(@T_NoteTitle,@T_NoteClassID,@T_NoteDes,@T_NoteKey,@T_DateTime,@T_NoteMes,@T_NoteFlag,@T_NoteImage,@Remark) ";
                }
                return (DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, strSql, parm) > 0) ? true : false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取相关ClassID
        /// </summary>
        /// <param name="strClass"></param>
        /// <returns></returns>
        public static string GetAboutClassMes(string strClass)
        {
            try
            {
                string strAClass = string.Empty;
                OleDbDataReader DataRead = DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT T_NoteClassID FROM T_Note_Class WHERE T_ClassLeave like '%{0}%'", strClass), null);
                if (DataRead.HasRows)
                {
                    while (DataRead.Read())
                    {
                        strAClass += DataRead["T_NoteClassID"].ToString() + ",";
                    }
                }
                DataRead.Close();
                DataRead.Dispose();
                return strAClass.Substring(0, strAClass.Length);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        /// <summary>
        /// 分页获取内容数据信息
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageCount"></param>
        /// <param name="RecordCount"></param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public static DataTable GetAllNoteInfo(int PageIndex, int PageSize, out int PageCount, out int RecordCount, string strWhere)
        {
            try
            {
                string strSql = " SELECT N.T_NoteID,N.T_NoteClassID,N.T_NoteTitle,N.T_DateTime,N.T_NoteImage,N.T_NoteFlag,N.T_BrowerCount,N.Remark,N.T_NoteDes,N.T_NoteKey,C.T_ClassName,C.T_ClassEnName FROM T_Note_Info N LEFT JOIN T_Note_Class C  ON N.T_NoteClassID=C.T_NoteClassID ";
                return DBUnlity.AccessHelper.ExecutePager(PageIndex, PageSize, "T_NoteID", "*", strSql, strWhere, " Remark ASC,T_NoteFlag desc,T_NoteID DESC ", out PageCount, out RecordCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取所有的微博信息
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageCount"></param>
        /// <param name="RecordCount"></param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public static DataTable GetAllTMes(int PageIndex, int PageSize, out int PageCount, out int RecordCount, string strWhere)
        {
            try
            {
                string strSql = " SELECT T_NoteID,T_DateTime,Remark,T_NoteDes FROM T_Note_Info  ";
                return DBUnlity.AccessHelper.ExecutePager(PageIndex, PageSize, "T_NoteID", "*", strSql, strWhere, " T_NoteID DESC ", out PageCount, out RecordCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取最新微博信息
        /// </summary>
        /// <param name="Top"></param>
        /// <returns></returns>
        public static OleDbDataReader GetTopTMes(string Top)
        {
            try
            {
                string strSql = string.Format(" SELECT TOP {0} T_NoteDes FROM T_Note_Info  WHERE  T_NoteClassID='' ORDER BY T_NoteID DESC ", Top);
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, strSql, null);
            }
            catch (Exception EX)
            {
                throw EX;
            }
        }
        /// <summary>
        /// 分页获取内容数据信息---生成静态列表页面
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageCount"></param>
        /// <param name="RecordCount"></param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public static DataTable HtmlGetAllNoteInfo(int PageIndex, int PageSize, out int PageCount, out int RecordCount, string strWhere,string strOrder)
        {
            try
            {
                string strSql = " SELECT  N.T_NoteID,N.T_NoteClassID,N.T_NoteTitle,N.T_NoteKey,N.T_NoteDes,N.T_DateTime,N.T_NoteImage,N.T_BrowerCount,N.T_NoteFlag,N.Remark,C.* FROM T_Note_Info N LEFT JOIN T_Note_Class C  ON N.T_NoteClassID=C.T_NoteClassID ";
                return DBUnlity.AccessHelper.ExecutePager(PageIndex, PageSize, "T_NoteID", "*", strSql, strWhere, strOrder, out PageCount, out RecordCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 分页获取内容数据信息---生成静态页面
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageCount"></param>
        /// <param name="RecordCount"></param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public static DataTable HtmlGetAllNoteInfo(int PageIndex, int PageSize, out int PageCount, out int RecordCount)
        {
            try
            {
                string strSql = " SELECT  N.*,C.T_ClassEnName,C.T_ClassName,C.T_NoteTemplete FROM T_Note_Info N LEFT JOIN T_Note_Class C  ON N.T_NoteClassID=C.T_NoteClassID ";
                return DBUnlity.AccessHelper.ExecutePager(PageIndex, PageSize, "T_NoteID", "*", strSql, "  WHERE N.Remark is null  or Remark='' ", " N.T_NoteClassID DESC,T_NoteFlag desc,T_NoteID DESC ", out PageCount, out RecordCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 更新信息生成状态
        /// </summary>
        /// <param name="strClass"></param>
        public static void UpdateHtmlState(string strClass,string strValue)
        {
            string strWhere = (string.IsNullOrEmpty(strClass)) ? "" : string.Format(" WHERE T_NoteID IN ({0})",strClass);
            DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" UPDATE T_Note_Info SET Remark='{0}' {1} ", strValue, strWhere), null);
        }
        /// <summary>
        /// 获取部分数据 用于生成页面右侧
        /// </summary>
        /// <param name="Top"></param>
        /// <param name="strWhere"></param>
        /// <param name="strOrder"></param>
        /// <returns></returns>
        public static OleDbDataReader HtmlGetTopNoteInfo(string Top, string strWhere, string strOrder)
        {
            try
            {
                string strSql = string.Format(" SELECT TOP {2} N.T_NoteID,N.T_NoteTitle,N.T_NoteImage,N.Remark,N.T_BrowerCount,C.T_ClassEnName FROM T_Note_Info N LEFT JOIN T_Note_Class C  ON N.T_NoteClassID=C.T_NoteClassID WHERE N.T_NoteClassID<>'' {0} {1} ", strWhere, strOrder, Top);
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, strSql, null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取一条信息数据
        /// </summary>
        /// <returns></returns>
        public static OleDbDataReader GetAllNoteInfo(string strNID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT * FROM T_Note_Info WHERE T_NoteID= {0} ", strNID), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取一条信息相关的标题部分  用于查看所有品论信息
        /// </summary>
        /// <param name="strNID"></param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteTitleMes(string strNID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT N.T_NoteID,N.T_NoteTitle,C.T_ClassEnName FROM T_Note_Info N LEFT JOIN T_Note_Class C ON N.T_NoteClassID=C.T_NoteClassID WHERE T_NoteID= {0} ", strNID), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取一条数据信息
        /// </summary>
        /// <returns></returns>
        public static OleDbDataReader GetAllNoteInfoMes(string strNID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT N.T_NoteTitle,N.T_NoteKey,N.T_NoteDes,C.T_ClassEnName,C.T_ClassName FROM T_Note_Info N LEFT JOIN T_Note_Class C ON N.T_NoteClassID=C.T_NoteClassID WHERE T_NoteID= {0} ", strNID), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 返回上一篇 下一篇信息
        /// </summary>
        /// <param name="strNID"></param>
        /// <param name="strType"></param>
        /// <returns></returns>
        public static OleDbDataReader GetNextUpMes(string strNID, string strType)
        {
            try
            {
                string strSql = string.Format("SELECT TOP 1 N.T_NoteTitle,N.T_NoteID,C.T_ClassEnName FROM T_Note_Info N LEFT JOIN T_Note_Class C ON N.T_NoteClassID=C.T_NoteClassID WHERE T_NoteID>{0}   ORDER BY T_NoteID ASC ", strNID);
                if (strType.ToLower() == "next")
                {
                    strSql = string.Format("SELECT TOP 1 N.T_NoteTitle,N.T_NoteID,C.T_ClassEnName FROM T_Note_Info N LEFT JOIN T_Note_Class C ON N.T_NoteClassID=C.T_NoteClassID WHERE T_NoteID<{0}   ORDER BY T_NoteID DESC ", strNID);
                }
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, strSql, null);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// 删除内容信息
        /// </summary>
        /// <param name="strClassID"></param>
        /// <returns></returns>
        public static bool DelNoteMes(string strNoteID)
        {
            try
            {
                bool note = (DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" DELETE FROM T_Note_Info WHERE T_NoteID IN ({0})  ", strNoteID), null) > 0) ? true : false;
                DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" DELETE FROM T_Leave_Info WHERE T_NoteID IN ({0})  ", strNoteID), null);
                return note;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 更新信息浏览次数
        /// </summary>
        /// <param name="strClass"></param>
        public static void UpdateReadCount(string strNID)
        {
            try
            {DBUnlity.AccessHelper.ExecuteNonQuery(DBUnlity.AccessHelper.ConnectionString, string.Format(" UPDATE T_Note_Info SET T_BrowerCount=T_BrowerCount+1 WHERE T_NoteID= {0} ", strNID), null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取信息浏览次数
        /// </summary>
        /// <param name="strClass"></param>
        public static string GetReadCount(string strNID)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteScalar(DBUnlity.AccessHelper.ConnectionString, string.Format(" SELECT T_BrowerCount FROM T_Note_Info  WHERE T_NoteID= {0} ", strNID), null).ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 根据条件返回指定的记录行数
        /// </summary>
        /// <param name="iTopCount"></param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteInfoByEnName(int iTopCount ,string strCols, string strWhere)
        {
            if (String.IsNullOrEmpty(strCols))
            {
                strCols = "* ";
            }
            if (iTopCount <= 0 )
            {
                iTopCount = 10;
            }
            if (!String.IsNullOrEmpty(strWhere))
            {
                strWhere = " and b.t_classenname= '" + strWhere + "'";
            }
            else
            {
                strWhere = " and 1=1 ";
            }
            try
            {
                return DBUnlity.AccessHelper.ExecuteReader(DBUnlity.AccessHelper.ConnectionString, " SELECT top "+ iTopCount +" a."+ strCols+" ,b.t_classenname FROM T_Note_Info a,t_note_class b WHERE a.t_noteclassid=b.t_noteclassid  " + strWhere + " order by a.t_datetime desc", null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取所有note类别
        /// </summary>
        /// <returns></returns>
        public static DataTable GetAllNoteClass()
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteDataSet(DBUnlity.AccessHelper.ConnectionString,"select T_classenname from t_note_class", null).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static DataTable GetNoteClassAllCols()
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteDataSet(DBUnlity.AccessHelper.ConnectionString, "select * from t_note_class", null).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static DataTable GetNoteInfoByClassId(string classid,string strCount)
        {
            try
            {
                return DBUnlity.AccessHelper.ExecuteDataSet(DBUnlity.AccessHelper.ConnectionString, "select top " + strCount + " * from t_note_info where T_NoteClassID = '" + classid + "' order by T_BrowerCount desc", null).Tables[0];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
